﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Bulky : BaseEnermy {
	// Use this for initialization
	void Start () {
        Vector3 vel = transform.GetComponent<Rigidbody2D>().velocity;
        vel.x = speed;
        transform.GetComponent<Rigidbody2D>().velocity = vel;
	}
	
	// Update is called once per frame
	void Update () {  
	}
    protected override void Dead()
    {
        Destroy(transform.GetComponent<CapsuleCollider2D>());
        Destroy(gameObject);
    }
    void OnCollisionEnter2D(Collision2D col)
    {
        if (col.transform.tag != Tag.ground)
        {
            Vector3 scale = transform.localScale;
            scale.x *= -1;
            transform.localScale = scale;
            Vector3 vel = transform.GetComponent<Rigidbody2D>().velocity;
            speed *= -1;
            vel.x = speed;
            transform.GetComponent<Rigidbody2D>().velocity = vel;
        }
    }
    void OnTriggerEnter2D(Collider2D col)
    {
        print(col.transform.tag);
        if (col.transform.tag == Tag.player)
        {
            col.gameObject.transform.GetComponent<Fox>().GetDamage(1);
        }
        if (col.transform.name == Tag.foot)
        {
          HP--;
        }
    }

    protected override void Attack()
    {
        throw new System.NotImplementedException();
    }

    protected override void Move()
    {
        throw new System.NotImplementedException();
    }

    protected override void OnMyEvent(EVENT_TYPE Event_Type, Component Sender, object Param = null)
    {
        
    }
    //void OnCollisionStay2D(Collision2D col)
    //{
    //    if (col.transform.name == "Player")
    //    {
    //        Vector3 vel = transform.GetComponent<Rigidbody2D>().velocity;
    //        vel.x = speed;
    //        transform.GetComponent<Rigidbody2D>().velocity = vel;
    //    }
    //}
}
